menuList[4].onclick();

// 遍历所有标签
function getExpress(){
    let expressUl = cl("expressUl");
    axios({
        url:'/admin/system/queryExpressType',
        method:'GET',
        })
        .then(data => {
            console.warn(data.data.data.data);
            expressUl.innerHTML ="";
            let i=0;
            for(let key in data.data.data.data){
                console.log(key);
                expressUl.innerHTML += `
                    <li class="expressLi" _id="${i}" name="${data.data.data.data[key].expressTypeId}" onclick="chooseExpressFun()">${data.data.data.data[key].expressType}</li>
                    `
                    i++;
                }
        })
        .catch(err => {
            console.log(err);
        })
}
getExpress()

// 选中标签
function chooseExpressFun(e){
    let expressLi = document.getElementsByClassName("expressLi")
    expressLi[expressid].style.color="black";
    expressLi[expressid].style.backgroundColor="white";
    e=e || window.event;
    var target=e.target || e.srcElement;
    expressid = target.getAttribute("_id")
    target.style.color="#fff";
    target.style.backgroundColor="#438Eb9";
    expressBrandid = target.getAttribute("name");
    let preActive = cl("preActive");
    preActive.innerHTML = `
        当前选中：${target.innerHTML}
    `

}

let expressBrandid =-1;
let expressid = 0;
// 添加标签
function openAddFun(){
    closeExpressFun()
    let addExpressWin = cl("addExpressWin");
    addExpressWin.style.display = "block";
}
function addExpressFun(){
    let addExpressInput = cl("addExpressInput");
    console.log("1111");
    axios({
        url:'/admin/system/addExpressType',
        method:'POST',
        params: {
            expressBrand:addExpressInput.value,
        }
        })
        .then(data => {
           console.log(data.data.code);
           if(data.data.code==20000){
                explain({
                    code:1,
                    msg:"添加成功",
                    time:3000
                })
                 closeExpressFun()
                getExpress()
            }
        })
        .catch(err => {
            console.log(err);
        })
}
// 修改标签
function openChangeFun(){
    closeExpressFun()
    let changeExpressWin = cl("changeExpressWin");
    if(expressBrandid == -1){
        explain({
            code:3,
            msg:"请选择需要修改的标签",
            time:3000
        })
   }else{
    changeExpressWin.style.display = "block";
   }    
}
function changeExpressFun(){
    let changeExpressInput = cl("changeExpressInput");
    let preActive = cl("preActive");
    console.warn(expressBrandid);
    console.log("1111");
    axios({
        url:'/admin/system/updateExpressType',
        method:'PUT',
        params: {
            expressBrand: changeExpressInput.value,
            expressBrandId: expressBrandid
            }
        })
        .then(data => {
           console.log(data.data);
           if(data.data.code==20000){
                explain({
                    code:1,
                    msg:"修改成功",
                    time:3000
                })
                closeExpressFun()
                 getExpress()
                 preActive.innerHTML= "当前选中：无"
                 expressBrandid = -1
                 expressid = 0;
            }
        })
        .catch(err => {
            console.log(err);
        })
}
// 删除标签
function openDelFun(){
    closeExpressFun()
    let delExpressWin = cl("delExpressWin");
   
    if(expressBrandid == -1){
        explain({
            code:3,
            msg:"请选择需要删除的标签",
            time:3000
        })
   }else{
     delExpressWin.style.display = "block";
   }    
}
function delExpressFun(){
    let preActive = cl("preActive");
   
    console.warn(expressBrandid);
    console.log("1111");
    
    axios({
        url:'/admin/system/deleteExpressType',
        method:'DELETE',
        params: {
            expressBrandId: expressBrandid
            }
        })
        .then(data => {
           console.log(data.data);
          
           if(data.data.code==20000){
                explain({
                    code:1,
                    msg:"删除成功",
                    time:3000
                })
                 closeExpressFun()
                 getExpress()
                 preActive.innerHTML= "当前选中：无"
                 expressBrandid = -1
                 expressid = 0;
            }
        })
        .catch(err => {
            console.log(err);
        })
}
// 关闭操作
function closeExpressFun(){
    let addExpressWin = cl("addExpressWin");
    let changeExpressWin = cl("changeExpressWin");
    let delExpressWin = cl("delExpressWin");
    addExpressWin.style.display = "none";
    changeExpressWin.style.display = "none";
    delExpressWin.style.display = "none";
}